import redis

def main():
    # 创建 Redis 连接
    redis_conn = redis.StrictRedis(host='192.168.88.144', port=6379, db=0)
    # 测试连接'
    try:
        # 测试 ping
        if redis_conn.ping():
            print("成功连接到 Redis！")
    except redis.ConnectionError:
        print("无法连接到 Redis。请检查 Redis 服务器是否正在运行。")
        return
    # 获取所有键
    keys = redis_conn.keys()
    for key in keys:
        key_str = key.decode('utf-8')
        value = redis_conn.get(key_str).decode()
        print(f"{key_str}:{value}")
if __name__ == "__main__":
    main()

